// pages/test/test.js
Page({
    data:{
    },
    onShow(e){
        this.onShowLoading();
    },
    test:function(e){
        wx.showModal({
            showCancel:false,
            title:"",
            success(res){
                if(res.confirm){

                }
                else if(res.cancel){

                };
            }
        });
        var that = this;
        wx.request({
          url: getApp().globalData.serverUrl,
          method:"GET",
          timeout:1500,
          data:{
            //各种数据的传送
            operation:"",
          },
          success(res){
            if(res.data == false){
                wx.showModal({
                    showCancel:false,
                    title:"请求失败,请重试",
                });
            }
            else{
                //成功获取到信息后的操作
                console.log(res);
            }
          },
          fail(res){
            wx.showModal({
                showCancel:false,
                title:"请求超时,请重试",
            });
          },
        });
    },
    onShowLoading:function(e){
        var that = this;
        wx.showLoading({
          title: '加载中',
          mask:true,
          success(res){
              that.setData({
                  "showLoadingState":true,
              })
          }
        })
        setTimeout(that.onHideLoading,1800)
    },
    onHideLoading:function(e){
        var that = this;
        if(that.data.showLoadingState == true){
            wx.hideLoading();
            that.setData({ 
                "showLoadingState":false,
            })
        }
    },
})